package com.biz.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

/**
 * @Author: yangfan
 * @Description: 中文字符处理工具类
 * @Date: 2022/11/14 17:34
 */
public class CharacterUtil {

    /**
     * 特殊字符过滤
     * @param str
     * @return
     * @throws PatternSyntaxException
     */
    public static String specialCharFilter(String str) throws PatternSyntaxException {
        String regEx = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？\\s*|\\t|\\r|\\n]";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(str);
        return m.replaceAll("").trim();
    }
}
